﻿using System;
using System.Collections.Generic;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using Alma.Infrastructure;

namespace Alma.Models
{
    [Table(Name = "Accounts")]
    public class AccountInfo : NotificationObject
    {
        #region Fields
        private Int32 id;
        private String name;
        private String gender;
        private String guid = System.Guid.NewGuid().ToString();
        private DateTime birthday = DateTime.Now.AddYears(-24);
        private String nation = "汉族";
        private String faith = "无";
        private String college;
        private String introduce;
        private String major;
        private String degree;
        private String status;
        private DateTime graduateDate = DateTime.Now;
        private String mobile;
        private String email;
        private String blog;
        private String qq;
        private String applyJob;
        private String province;
        private String city;
        private String address;
        private String postcode;
        private String preCompany;
        private String political;
        private String idType = "身份证";
        private String cardNumber;
        private Int32 yearsOfExperience = 0;
        private Int32 currentSalary = 0;
        private String maritalStatus = "未婚";
        private String permanentResidence;
        private byte[] avatar;
        #endregion

        #region Properties
        [Column(Name = "Id", IsPrimaryKey = true, CanBeNull = false, IsDbGenerated = true, DbType = "INT NOT NULL Identity", AutoSync = AutoSync.OnInsert)]
        public Int32 Id
        {
            get { return id; }
            set
            {
                id = value;
                RaisePropertyChanged(() => Id);
            }
        }

        [Column(Name = "Name")]
        public String Name
        {
            get { return name; }
            set
            {
                name = value;
                RaisePropertyChanged(() => Name);
            }
        }

        [Column(Name = "Guid")]
        public String Guid
        {
            get { return guid; }
            set
            {
                guid = value;
                RaisePropertyChanged(() => Guid);
            }
        }

        /// <summary>
        /// 生日
        /// </summary>
        [Column(Name = "Birthday")]
        public DateTime Birthday
        {
            get { return birthday; }
            set
            {
                birthday = value;
                RaisePropertyChanged(() => Birthday);
            }
        }

        /// <summary>
        /// 年龄
        /// </summary>
        public Int32 Age
        {
            get
            {
                if (Birthday.DayOfYear > DateTime.Now.DayOfYear)
                {
                    return DateTime.Now.Year - Birthday.Year - 1;
                }
                else
                {
                    return DateTime.Now.Year - Birthday.Year;
                }
            }
        }

        /// <summary>
        /// 民族
        /// </summary>
        [Column]
        public String Nation
        {
            get { return nation; }
            set
            {
                nation = value;
                RaisePropertyChanged(() => Nation);
            }
        }

        /// <summary>
        /// 宗教信仰
        /// </summary>
        [Column]
        public String Faith
        {
            get { return faith; }
            set
            {
                faith = value;
                RaisePropertyChanged(() => Faith);
            }
        }

        [Column(Name = "College")]
        public String College
        {
            get { return college; }
            set
            {
                college = value;
                RaisePropertyChanged(() => College);
            }
        }

        /// <summary>
        /// 介绍
        /// </summary>
        [Column(Name = "Introduce")]
        public String Introduce
        {
            get { return introduce; }
            set
            {
                introduce = value;
                RaisePropertyChanged(() => Introduce);
            }
        }

        /// <summary>
        /// 专业
        /// </summary>
        [Column(Name = "Major")]
        public String Major
        {
            get { return major; }
            set
            {
                major = value;
                RaisePropertyChanged(() => Major);
            }
        }

        /// <summary>
        /// 学历
        /// </summary>
        [Column(Name = "Degree")]
        public String Degree
        {
            get { return degree; }
            set
            {
                degree = value;
                RaisePropertyChanged(() => Degree);
            }
        }

        /// <summary>
        /// 目前状态
        /// <summary>
        [Column(Name = "Status")]
        public String Status
        {
            get { return status; }
            set
            {
                status = value;
                RaisePropertyChanged(() => Status);
            }
        }

        /// <summary>
        /// 毕业时间
        /// </summary>
        [Column(Name = "GraduateDate")]
        public DateTime GraduateDate
        {
            get { return graduateDate; }
            set
            {
                graduateDate = value;
                RaisePropertyChanged(() => GraduateDate);
            }
        }

        [Column(Name = "Mobile")]
        public String Mobile
        {
            get { return mobile; }
            set
            {
                mobile = value;
                RaisePropertyChanged(() => Mobile);
            }
        }

        [Column(Name = "Email")]
        public String Email
        {
            get { return email; }
            set
            {
                email = value;
                RaisePropertyChanged(() => Email);
            }
        }
        
        /// <summary>
        /// 博客
        /// </summary>
        [Column(Name = "Blog")]
        public String Blog
        {
            get { return blog; }
            set
            {
                blog = value;
                RaisePropertyChanged(() => Blog);
            }
        }

        /// <summary>
        /// QQ
        /// </summary>
        [Column]
        public String QQ
        {
            get { return qq; }
            set
            {
                qq = value;
                RaisePropertyChanged(() => QQ);
            }
        }

        /// <summary>
        /// 申请的职务
        /// </summary>
        [Column(Name = "ApplyJob")]
        public String ApplyJob
        {
            get { return applyJob; }
            set
            {
                applyJob = value;
                RaisePropertyChanged(() => ApplyJob);
            }
        }

        /// <summary>
        /// 省份
        /// </summary>
        [Column(Name = "Province")]
        public String Province
        {
            get { return province; }
            set
            {
                province = value;
                RaisePropertyChanged(() => Province);
            }
        }

        /// <summary>
        /// 城市
        /// </summary>
        [Column(Name = "City")]
        public String City
        {
            get { return city; }
            set
            {
                city = value;
                RaisePropertyChanged(() => City);
            }
        }

        /// <summary>
        /// 地址
        /// </summary>
        [Column(Name = "Address")]
        public String Address
        {
            get { return address; }
            set
            {
                address = value;
                RaisePropertyChanged(() => Address);
            }
        }

        /// <summary>
        /// 邮编
        /// </summary>
        [Column(Name = "Postcode")]
        public String Postcode
        {
            get { return postcode; }
            set
            {
                postcode = value;
                RaisePropertyChanged(() => Postcode);
            }
        }

        /// <summary>
        /// 前就职单位
        /// </summary>
        [Column(Name = "PreCompany")]
        public String PreCompany
        {
            get { return preCompany; }
            set
            {
                preCompany = value;
                RaisePropertyChanged(() => PreCompany);
            }
        }

        /// <summary>
        /// 政治面貌
        /// <summary>
        [Column(Name = "Political")]
        public String Political
        {
            get { return political; }
            set
            {
                political = value;
                RaisePropertyChanged(() => Political);
            }
        }

        /// <summary>
        /// 获取和设置性别
        /// </summary>
        [Column(Name = "Gender")]
        public String Gender
        {
            get { return gender; }
            set
            {
                gender = value;
                RaisePropertyChanged(() => Gender);
            }
        }

        /// <summary>
        /// 获取和设置工作年限
        /// </summary>
        [Column(Name = "YearsOfExperience")]
        public Int32 YearsOfExperience
        {
            get { return yearsOfExperience; }
            set
            {
                yearsOfExperience = value;
                RaisePropertyChanged(() => YearsOfExperience);
            }
        }

        /// <summary>
        /// 当前年薪
        /// </summary>
        [Column(Name = "CurrentSalary")]
        public Int32 CurrentSalary
        {
            get { return currentSalary; }
            set
            {
                currentSalary = value;
                RaisePropertyChanged(() => CurrentSalary);
            }
        }

        /// <summary>
        /// 证件类型
        /// </summary>
        [Column(Name = "IDType")]
        public String IDType
        {
            get { return idType; }
            set
            {
                idType = value;
                RaisePropertyChanged(() => IDType);
            }
        }

        /// <summary>
        /// 婚姻状况
        /// </summary>
        [Column(Name = "MaritalStatus")]
        public String MaritalStatus
        {
            get { return maritalStatus; }
            set
            {
                maritalStatus = value;
                RaisePropertyChanged(() => MaritalStatus);
            }
        }

        /// <summary>
        /// 证件号码
        /// </summary>
        [Column]
        public String CardNumber
        {
            get { return cardNumber; }
            set
            {
                cardNumber = value;
                RaisePropertyChanged(() => CardNumber);
            }
        }
        /// <summary>
        /// 户口所在地
        /// </summary>
        [Column]
        public String PermanentResidence
        {
            get { return permanentResidence; }
            set
            {
                permanentResidence = value;
                RaisePropertyChanged(() => PermanentResidence);
            }
        }

        /// <summary>
        /// 头像
        /// </summary>
        [Column(Name = "Avatar", DbType = "image", UpdateCheck= UpdateCheck.Never)]
        public byte[] Avatar
        {
            get { return avatar; }
            set
            {
                avatar = value;
                RaisePropertyChanged(() => Avatar);
            }
        }
        #endregion
    }
}
